package com.作业.Day14;

import java.io.File;

public class Homework3 {
    public static void main(String[] args) {
        File file = new File("D:\\Desktop\\粤嵌\\JAVA-GZ2524班\\2025年7月9日\\课后作业\\集合作业1\\课后作业\\西游记");
        /**
         * 遍历的是File下一级的文件
         */
        int i = 0;
        for (String name : file.list()) {
            i+=1;
            System.out.println(name);
            StringBuilder sb = new StringBuilder(name);
            sb.insert(0,"西游记_00"+i+"_[小说-测试]");
            String s = new String(sb);
            //第一个文件
            File file1 = new File(file, name);
            //第二个文件
            File file2 = new File(file,s);
            boolean b = file1.renameTo(file2);
            if (b) {
                System.out.println("成功");
            }
            else
                System.out.println("失败");

        }
    }
}